Maximum Width of Binary Tree
Easy
Question
Given the root of a tree, return the maximum width of the tree.
Input: root = [1, 2, 3, None, None, 6]
Output: 2
If the root is at the 0th level, the maximum width of the tree is at the 1st level with 2 nodes.
Input: root = [1, 2, 3, 4, 5, None, None, 8]
Output: 2
If the root is at the 0th level, the tree has a maximum width of 2 nodes on the 1st or 2nd levels.
Clarify the problem
What are some questions you'd ask an interviewer?
Understand the problem
What is the maximum width of this tree? root = [1, 2, 3, 4, 5, 6, 7, 8]
1
2
3
4
All test cases pass! 🎉
Time limit exceeded
InputExpected OutputActual Output
Standard OutputScroll down...
Login or signup to save your code.
Uh oh... looks like you don't yet have access.
Not sure what this unlocks? Check out a free pattern section.